<html>
<head><meta charset="utf-8"><title>Building rustc for multiple targets in a single repo? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc.20for.20multiple.20targets.20in.20a.20single.20repo.3F.html">Building rustc for multiple targets in a single repo?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241088773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc%20for%20multiple%20targets%20in%20a%20single%20repo%3F/near/241088773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Richard Cobbe <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc.20for.20multiple.20targets.20in.20a.20single.20repo.3F.html#241088773">(Jun 01 2021 at 23:32)</a>:</h4>
<p>As I've been working on a PR for rustc, I've had to switch back and forth between multiple targets during development and testing, primarily {x86_64,i686}-pc-windows-msvc.  I'm finding it harder than I'd like to switch back and forth between these two platforms, and I'm wondering if this is expected behavior in x.py.</p>
<p>In the most recent case, after fixing a bug that only affected i686-pc-windows-msvc, I wanted to switch back to x86_64 to ensure I didn't introduce regressions there, but running <code>x.py test --build=x86_64-pc-windows-msvc ...</code> wasn't sufficient; it still tried to build the i686 version of rustc.  I was able to fix this by deleting build/bootstrap and rerunning x.py, which suggests that the target triple is baked into bootstrap in some sense, and that x.py doesn't realize that bootstrap is stale and needs to be rebuilt.  But it's kind of a hassle to have to do this to switch architectures -- is this expected behavior?</p>



<a name="241093080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc%20for%20multiple%20targets%20in%20a%20single%20repo%3F/near/241093080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc.20for.20multiple.20targets.20in.20a.20single.20repo.3F.html#241093080">(Jun 02 2021 at 00:36)</a>:</h4>
<p>Hm, that's strange. It seems to work OK for me, though there certainly is a lot of complexity in how the build/host/targets are computed. Do you have anything in <code>config.toml</code>? </p>
<p>The default <code>build</code> target will get embedded in the bootstrap binary based on the <code>--build</code> flag or the config value or the computed value. But it should honor the <code>--build</code> flag if you later choose a different value.  It is "sticky" in a sense if you later run x.py without <code>--build</code> or a config value, it will use whatever it was built with the first time.</p>
<p>However, I would recommend not necessarily switching <code>build</code> around. That is only relevant for the build system (like rustbuild itself), and it should be fine to leave that as x86_64-pc-windows-msvc, and switch the <code>host</code> as needed (or just the <code>target</code> if you are only testing the compiled results of tests, and not the compiler itself).</p>



<a name="241093651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Building%20rustc%20for%20multiple%20targets%20in%20a%20single%20repo%3F/near/241093651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Richard Cobbe <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Building.20rustc.20for.20multiple.20targets.20in.20a.20single.20repo.3F.html#241093651">(Jun 02 2021 at 00:45)</a>:</h4>
<p>No, my config.toml is pretty minimal:</p>
<div class="codehilite"><pre><span></span><code>profile = &quot;compiler&quot;
changelog-seen = 2

[rust]
debug-logging = true

[llvm]
download-ci-llvm = true
</code></pre></div>
<p>I didn't know that about the --build, --host, and --target switches, though, thanks!  (Cross-compilers can be a little confusing.)  It sounds like either <code>--host</code> or <code>--target</code> is what I'm looking for; I'll try that in the future.  Thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>